package com.stockz.ui.swing.charting.view;

import java.awt.Point;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.stockz.core.model.Bar;
import com.stockz.core.model.Scrip;
import com.stockz.core.util.CoreConstant.TIME_UNIT;
import com.stockz.ui.swing.charting.display.Displayable;
import com.stockz.ui.swing.charting.model.Shape;
import com.stockz.ui.swing.charting.painter.chart.StockChartPainter;

public class StockChartPanelState{

	public StockChartPanelState(StockChartPanel stockChartPanel) {
		this.stockChartPanel = stockChartPanel;
	}
	
	private List<Bar> barList = new ArrayList<Bar>();
	private List<Bar> backupBarList = new ArrayList<Bar>();
	private Scrip scrip = new Scrip();
	
	private StockRectangle chartRectangle = new StockRectangle();
	private StockRectangle priceRectangle = new StockRectangle();
	private StockRectangle volumeRectangle = new StockRectangle();
	private StockRectangle drawingRectangle = new StockRectangle();
	
	private final Set<StockRectangle> stockRectangleSet = new HashSet<StockRectangle>();
	private final Set<Displayable> displayableSet = new HashSet<Displayable>();
	private final Set<Shape> shapeSet = new HashSet<Shape>();
	

	private int timeUnitSpace = 5;
	private TIME_UNIT currentTimeUnit = TIME_UNIT.DAILY;
	private boolean gridVisible = true;
	private boolean crosshairVisible = true;
	private boolean semiLog = false;
	private Point currentPoint = new Point();
	
	private int startIndex = -1;
	private int endIndex = -1;
	private double maximumPriceVisible = Double.MIN_VALUE;
	private double minimumPriceVisible = Double.MAX_VALUE;
	private double maximumVolumeVisible = Double.MIN_VALUE;
	private double minimumVolumeVisible = Double.MAX_VALUE;
	
	private StockChartPainter stockChartPainter;
	private StockChartPanel stockChartPanel;
	
	public List<Bar> getBarList() {
		return barList;
	}

	public StockRectangle getChartRectangle() {
		return chartRectangle;
	}
	public void setChartRectangle(StockRectangle chartRectangle) {
		this.chartRectangle = chartRectangle;
	}
	public StockRectangle getVolumeRectangle() {
		return volumeRectangle;
	}
	public void setVolumeRectangle(StockRectangle volumeRectangle) {
		this.volumeRectangle = volumeRectangle;
	}

	public int getStartIndex() {
		return startIndex;
	}
	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}
	public int getEndIndex() {
		return endIndex;
	}
	public void setEndIndex(int endIndex) {
		this.endIndex = endIndex;
	}
	public double getMaximumPriceVisible() {
		return maximumPriceVisible;
	}
	public void setMaximumPriceVisible(double maximumPriceVisible) {
		this.maximumPriceVisible = maximumPriceVisible;
	}
	public double getMinimumPriceVisible() {
		return minimumPriceVisible;
	}
	public void setMinimumPriceVisible(double minimumPriceVisible) {
		this.minimumPriceVisible = minimumPriceVisible;
	}
	public double getMaximumVolumeVisible() {
		return maximumVolumeVisible;
	}
	public void setMaximumVolumeVisible(double maximumVolumeVisible) {
		this.maximumVolumeVisible = maximumVolumeVisible;
	}
	public double getMinimumVolumeVisible() {
		return minimumVolumeVisible;
	}
	public void setMinimumVolumeVisible(double minimumVolumeVisible) {
		this.minimumVolumeVisible = minimumVolumeVisible;
	}
	public Scrip getScrip() {
		return scrip;
	}
	public void setScrip(Scrip scrip) {
		this.scrip = scrip;
	}
	public StockRectangle getDrawingRectangle() {
		return drawingRectangle;
	}
	public void setDrawingRectangle(StockRectangle drawingRectangle) {
		this.drawingRectangle = drawingRectangle;
	}
	
	public void setTimeUnitSpace(int timeUnitSpace) {
		if(timeUnitSpace > 0){
			this.timeUnitSpace = timeUnitSpace;
		}
	}

	public int getTimeUnitSpace() {
		return timeUnitSpace;
	}

	public boolean isGridVisible() {
		return gridVisible;
	}

	public void setGridVisible(boolean gridVisible) {
		this.gridVisible = gridVisible;
	}

	public Point getCurrentPoint() {
		return currentPoint;
	}

	public void setCurrentPoint(Point currentPoint) {
		this.currentPoint = currentPoint;
	}

	public boolean isCrosshairVisible() {
		return crosshairVisible;
	}

	public void setCrosshairVisible(boolean crosshairVisible) {
		this.crosshairVisible = crosshairVisible;
	}

	public boolean isSemiLog() {
		return semiLog;
	}

	public void setSemiLog(boolean semiLog) {
		this.semiLog = semiLog;
	}

	public List<Bar> getBackupBarList() {
		return backupBarList;
	}

	public StockChartPainter getStockChartPainter() {
		return stockChartPainter;
	}

	public void setStockChartPainter(StockChartPainter stockChartPainter) {
		this.stockChartPainter = stockChartPainter;
	}

	public TIME_UNIT getCurrentTimeUnit() {
		return currentTimeUnit;
	}

	public void setCurrentTimeUnit(TIME_UNIT currentTimeUnit) {
		this.currentTimeUnit = currentTimeUnit;
	}

	public Set<StockRectangle> getStockRectangleSet() {
		return stockRectangleSet;
	}

	public void setBarList(List<Bar> barList) {
		this.barList = barList;
	}
	public Set<Displayable> getDisplayableSet() {
		return displayableSet;
	}

	public StockRectangle getPriceRectangle() {
		return priceRectangle;
	}

	public void setPriceRectangle(StockRectangle priceRectangle) {
		this.priceRectangle = priceRectangle;
	}

	public StockChartPanel getStockChartPanel() {
		return stockChartPanel;
	}

	public void setStockChartPanel(StockChartPanel stockChartPanel) {
		this.stockChartPanel = stockChartPanel;
	}

	public Set<Shape> getShapeSet() {
		return shapeSet;
	}
}